import {user} from "./user";
import {sleep} from "./sleep";
import {de, STR} from "./STR";
export class abstract_point{

    /**
     *
     * @param user {user} 对象
     * @param time {Number} 执行次数
     */
    constructor(user,time){
        if(user&&!Object.isFrozen(user)){
            this.time=time;
            this.user=user;
            this.interval=1;
        }else {
            throw new Error(de(STR.USERERROR));
        }

    }

    async request(){
        return 0;
    }


    async excute(){
        if(!await this.user.check())return;
        let time=this.time;
        for(let i=0;i<time;i++){
            await sleep(this.interval);
            await this.request();
            console.log(`${this.nickName} - 第${i+1}次`);
        }
    }

    async async_excute(){
        if(!await this.user.check())return;
        let time=this.time*10;
        for(let i=0;i<time;i++){
            this.request();
            console.log(`${this.nickName} - 第${i+1}次`);
        }
    }

}